package cn.edu.sgu.www.mhxysy.service.wenshi.impl;

import cn.edu.sgu.www.mhxysy.entity.wenshi.WenshiViewAttribute;
import cn.edu.sgu.www.mhxysy.mapper.wenshi.WenshiViewAttributeMapper;
import cn.edu.sgu.www.mhxysy.service.wenshi.WenshiViewAttributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Service
public class WenshiViewAttributeServiceImpl implements WenshiViewAttributeService {

	private final WenshiViewAttributeMapper wenshiViewAttributeMapper;

	@Autowired
	public WenshiViewAttributeServiceImpl(WenshiViewAttributeMapper wenshiViewAttributeMapper) {
		this.wenshiViewAttributeMapper = wenshiViewAttributeMapper;
	}

	@Override
	public List<WenshiViewAttribute> selectAll() {
		return wenshiViewAttributeMapper.selectList(null);
	}

	@Override
	public String selectNameById(Integer id) {
		WenshiViewAttribute viewAttribute = wenshiViewAttributeMapper.selectById(id);

		if (viewAttribute != null) {
			return viewAttribute.getName();
		}

		return null;
	}

	@Override
	public List<WenshiViewAttribute> selectByWenshiId(Integer wenshiId) {
		if (wenshiId == null) {
			return new ArrayList<>();
		}

		return wenshiViewAttributeMapper.selectByWenshiId(wenshiId);
	}

}